| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 uint32_t nsects() const { return segment_command_.nsects; } | 134 uint32_t nsects() const { return segment_command_.nsects; } |
| 135 | 135 |
| 136 //! \brief Obtain section information by section name. | 136 //! \brief Obtain section information by section name. |
| 137 //! | 137 //! |
| 138 //! \param[in] section_name The name of the section to search for, without the | 138 //! \param[in] section_name The name of the section to search for, without the |
| 139 //! leading segment name. For example, use `"__text"`, not | 139 //! leading segment name. For example, use `"__text"`, not |
| 140 //! `"__TEXT,__text"` or `"__TEXT.__text"`. | 140 //! `"__TEXT,__text"` or `"__TEXT.__text"`. |
| 141 //! \param[out] address The actual address that the section was loaded at in | 141 //! \param[out] address The actual address that the section was loaded at in |
| 142 //! memory, taking any “slide” into account if the section did not load at | 142 //! memory, taking any “slide” into account if the section did not load at |
| 143 //! its preferred address as stored in the Mach-O image file. This | 143 //! its preferred address as stored in the Mach-O image file. This |
| 144 //! parameter can be `NULL`. | 144 //! parameter can be `nullptr`. |
| 145 //! | 145 //! |
| 146 //! \return A pointer to the section information if it was found, or `NULL` if | 146 //! \return A pointer to the section information if it was found, or `nullptr` |
| 147 //! it was not found. The caller does not take ownership; the lifetime of | 147 //! if it was not found. The caller does not take ownership; the lifetime |
| 148 //! the returned object is scoped to the lifetime of this | 148 //! of the returned object is scoped to the lifetime of this |
| 149 //! MachOImageSegmentReader object. | 149 //! MachOImageSegmentReader object. |
| 150 //! | 150 //! |
| 151 //! \note The process_types::section::addr field gives the section’s preferred | 151 //! \note The process_types::section::addr field gives the section’s preferred |
| 152 //! load address as stored in the Mach-O image file, and is not adjusted | 152 //! load address as stored in the Mach-O image file, and is not adjusted |
| 153 //! for any “slide” that may have occurred when the image was loaded. | 153 //! for any “slide” that may have occurred when the image was loaded. |
| 154 //! | 154 //! |
| 155 //! \sa MachOImageReader::GetSectionByName() | 155 //! \sa MachOImageReader::GetSectionByName() |
| 156 const process_types::section* GetSectionByName( | 156 const process_types::section* GetSectionByName( |
| 157 const std::string& section_name, | 157 const std::string& section_name, |
| 158 mach_vm_address_t* address) const; | 158 mach_vm_address_t* address) const; |
| 159 | 159 |
| 160 //! \brief Obtain section information by section index. | 160 //! \brief Obtain section information by section index. |
| 161 //! | 161 //! |
| 162 //! \param[in] index The index of the section to return, in the order that it | 162 //! \param[in] index The index of the section to return, in the order that it |
| 163 //! appears in the segment load command. Unlike | 163 //! appears in the segment load command. Unlike |
| 164 //! MachOImageReader::GetSectionAtIndex(), this is a 0-based index. This | 164 //! MachOImageReader::GetSectionAtIndex(), this is a 0-based index. This |
| 165 //! parameter must be in the range of valid indices aas reported by | 165 //! parameter must be in the range of valid indices aas reported by |
| 166 //! nsects(). | 166 //! nsects(). |
| 167 //! \param[out] address The actual address that the section was loaded at in | 167 //! \param[out] address The actual address that the section was loaded at in |
| 168 //! memory, taking any “slide” into account if the section did not load at | 168 //! memory, taking any “slide” into account if the section did not load at |
| 169 //! its preferred address as stored in the Mach-O image file. This | 169 //! its preferred address as stored in the Mach-O image file. This |
| 170 //! parameter can be `NULL`. | 170 //! parameter can be `nullptr`. |
| 171 //! | 171 //! |
| 172 //! \return A pointer to the section information. If \a index is out of range, | 172 //! \return A pointer to the section information. If \a index is out of range, |
| 173 //! execution is aborted. The caller does not take ownership; the | 173 //! execution is aborted. The caller does not take ownership; the |
| 174 //! lifetime of the returned object is scoped to the lifetime of this | 174 //! lifetime of the returned object is scoped to the lifetime of this |
| 175 //! MachOImageSegmentReader object. | 175 //! MachOImageSegmentReader object. |
| 176 //! | 176 //! |
| 177 //! \note The process_types::section::addr field gives the section’s preferred | 177 //! \note The process_types::section::addr field gives the section’s preferred |
| 178 //! load address as stored in the Mach-O image file, and is not adjusted | 178 //! load address as stored in the Mach-O image file, and is not adjusted |
| 179 //! for any “slide” that may have occurred when the image was loaded. | 179 //! for any “slide” that may have occurred when the image was loaded. |
| 180 //! \note Unlike MachOImageReader::GetSectionAtIndex(), this method does not | 180 //! \note Unlike MachOImageReader::GetSectionAtIndex(), this method does not |
| 181 //! accept out-of-range values for \a index, and aborts execution instead | 181 //! accept out-of-range values for \a index, and aborts execution instead |
| 182 //! of returning `NULL` upon encountering an out-of-range value. This is | 182 //! of returning `nullptr` upon encountering an out-of-range value. This |
| 183 //! because this method is expected to be used in a loop that can be | 183 //! is because this method is expected to be used in a loop that can be |
| 184 //! limited to nsects() iterations, so an out-of-range error can be | 184 //! limited to nsects() iterations, so an out-of-range error can be |
| 185 //! treated more harshly as a logic error, as opposed to a data error. | 185 //! treated more harshly as a logic error, as opposed to a data error. |
| 186 //! | 186 //! |
| 187 //! \sa MachOImageReader::GetSectionAtIndex() | 187 //! \sa MachOImageReader::GetSectionAtIndex() |
| 188 const process_types::section* GetSectionAtIndex( | 188 const process_types::section* GetSectionAtIndex( |
| 189 size_t index, | 189 size_t index, |
| 190 mach_vm_address_t* address) const; | 190 mach_vm_address_t* address) const; |
| 191 | 191 |
| 192 //! Returns whether the segment slides. | 192 //! Returns whether the segment slides. |
| 193 //! | 193 //! |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 InitializationStateDcheck initialized_; | 247 InitializationStateDcheck initialized_; |
| 248 InitializationStateDcheck initialized_slide_; | 248 InitializationStateDcheck initialized_slide_; |
| 249 | 249 |
| 250 DISALLOW_COPY_AND_ASSIGN(MachOImageSegmentReader); | 250 DISALLOW_COPY_AND_ASSIGN(MachOImageSegmentReader); |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 } // namespace crashpad | 253 } // namespace crashpad |
| 254 | 254 |
| 255 #endif // CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SEGMENT_READER_H_ | 255 #endif // CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SEGMENT_READER_H_ |
| OLD | NEW |