def segment_by_type(type)
      type = Util.to_constant(Constants::PT, type)
      each_segments.find { |seg| seg.header.p_type == type }
    end
def segment_by_type(type)
      type = Util.to_constant(Constants::PT, type)
      each_segments.find { |seg| seg.header.p_type == type }
    end
Get the first segment with +p_type=type+.
 The available types are listed in {ELFTools::Constants::PT}.

 @note
   This method will return the first segment found,
   to found all segments with specific type you can use {#segments_by_type}.
 @param [Integer, Symbol, String] type
   See examples for clear usage.
 @return [ELFTools::Segments::Segment] The target segment.
 @example
   # type as an integer
   elf.segment_by_type(ELFTools::Constants::PT_NOTE)
   #=>  #<ELFTools::Segments::NoteSegment:0x005629dda1e4f8>

   elf.segment_by_type(4) # PT_NOTE
   #=>  #<ELFTools::Segments::NoteSegment:0x005629dda1e4f8>

   # type as a symbol
   elf.segment_by_type(:PT_NOTE)
   #=>  #<ELFTools::Segments::NoteSegment:0x005629dda1e4f8>

   # you can do this
   elf.segment_by_type(:note) # will be transformed into `PT_NOTE`
   #=>  #<ELFTools::Segments::NoteSegment:0x005629dda1e4f8>

   # type as a string
   elf.segment_by_type('PT_NOTE')
   #=>  #<ELFTools::Segments::NoteSegment:0x005629dda1e4f8>

   # this is ok
   elf.segment_by_type('note') # will be tranformed into `PT_NOTE`
   #=>  #<ELFTools::Segments::NoteSegment:0x005629dda1e4f8>
 @example
   elf.segment_by_type(1337)
   # ArgumentError: No constants in Constants::PT is 1337

   elf.segment_by_type('oao')
   # ArgumentError: No constants in Constants::PT named "PT_OAO"
 @example
   elf.segment_by_type(0)
   #=> nil # no such segment exists